﻿<Page x:Class="SsTool.Metadata.EntityMetadataPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="800"
	Title="EntityMetadataPage">
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="200"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <StackPanel Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Left" Orientation="Horizontal">
                <Button Name="_ctlBtnCreate" Content="Create" Click="_ctlBtnCreate_Click" Margin="5" />
                <Button Name="_ctlBtnUpdate" Content="Update"  Margin="5" Click="_ctlBtnUpdate_Click" />
                <Button Name="_ctlBtnDelete" Content="Delete" Margin="5"/>
                <Button Name="_ctlBtnToTable" Content="ToTable" Margin="5" Click="_ctlBtnToTable_Click" />
            </StackPanel>
            <Border Grid.Row="1" Grid.Column="0" Grid.RowSpan="2" BorderThickness="1" BorderBrush="Black" Margin="5,0,5,5">
                <DataGrid Name="_ctlGrid" BorderThickness="0" CanUserAddRows="False" IsReadOnly="True" AutoGenerateColumns="False" SelectionMode="Single" SelectionChanged="_ctlGrid_SelectionChanged">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="Caption" Binding="{Binding Caption}" Width="*"/>
                        <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*"/>
                    </DataGrid.Columns>
                </DataGrid>
            </Border>
            <TabControl Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" Margin="0,0,5,5">
                <TabItem>
                    <TabItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="../Resources/Properties.png" Margin="0,0,5,0" />
                            <TextBlock Text="属性列表"/>
                        </StackPanel>
                    </TabItem.Header>
                    <TabItem.Content>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <StackPanel Grid.Row="0" Orientation="Horizontal">
                                <Button Name="_ctlAddProperty" Margin="0,0,0,5" Click="_ctlAddProperty_Click">
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="../Resources/add.png"/>
                                        <TextBlock Text="添加属性" VerticalAlignment="Center"/>
                                    </StackPanel>
                                </Button>
                                <Button Name="_ctlEditProperty" Margin="5,0,0,5" Click="_ctlEditProperty_Click">
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="../Resources/properties.png"/>
                                        <TextBlock Text="修改属性" VerticalAlignment="Center"/>
                                    </StackPanel>
                                </Button>
                                <Button Name="_ctlDeleteProperty" Margin="5,0,0,5" Click="_ctlDeleteProperty_Click">
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="../Resources/delete.png"/>
                                        <TextBlock Text="删除属性" VerticalAlignment="Center"/>
                                    </StackPanel>
                                </Button>
                            </StackPanel>
                            <DataGrid Grid.Row="1" Name="_ctlGridProperty" IsReadOnly="True" AutoGenerateColumns="False">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="Caption" Binding="{Binding Caption}" Width="*"/>
                                    <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*"/>
                                    <DataGridCheckBoxColumn Header="Identity" Binding="{Binding Path=IsIdentity}"/>
                                    <DataGridCheckBoxColumn Header="允许为空" Binding="{Binding Path=IsNullable}"/>
                                    <DataGridCheckBoxColumn Header="系统字段" Binding="{Binding Path=IsSystem}"/>
                                    <DataGridTextColumn Header="Type" Binding="{Binding Path=Type.Caption}" Width="*"/>
                                    <DataGridTextColumn Header="MinLength" Binding="{Binding Path=MinLength}" Width="*"/>
                                    <DataGridTextColumn Header="MaxLength" Binding="{Binding Path=MaxLength}" Width="*"/>
                                    <DataGridTextColumn Header="Order" Binding="{Binding Path=OrderIndex}" Width="*"/>
                                </DataGrid.Columns>
                            </DataGrid>
                        </Grid>
                    </TabItem.Content>
                </TabItem>
                <TabItem>
                    <TabItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="../Resources/map.png" Margin="0,0,5,0"/>
                            <TextBlock Text="关联的数据"/>
                        </StackPanel>
                    </TabItem.Header>
                    <TabItem.Content>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <StackPanel Grid.Row="0" Orientation="Horizontal">
                                <Button Name="_ctlAddRelation" Margin="0,0,0,5" Click="_ctlAddRelation_Click">
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="../Resources/add.png"/>
                                        <TextBlock Text="添加关联实体" VerticalAlignment="Center"/>
                                    </StackPanel>
                                </Button>
                                <Button Name="_ctlDeleteRelation" Margin="5,0,0,5" Click="_ctlDeleteRelation_Click">
                                    <StackPanel Orientation="Horizontal">
                                        <Image Source="../Resources/delete.png"/>
                                        <TextBlock Text="删除关联实体" VerticalAlignment="Center"/>
                                    </StackPanel>
                                </Button>
                            </StackPanel>
                            <DataGrid Name="_ctlGridRelation" Grid.Row="1" AutoGenerateColumns="False" IsReadOnly="True">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="名称" Width="*" Binding="{Binding Path=Name}"/>
                                    <DataGridTextColumn Header="描述" Width="*" Binding="{Binding Path=Caption}"/>
                                </DataGrid.Columns>
                            </DataGrid>
                        </Grid>
                    </TabItem.Content>
                </TabItem>
                <TabItem>
                    <TabItem.Header>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="../Resources/object.png" Margin="0,0,5,0"/>
                            <TextBlock Text="被引用数据"/>
                        </StackPanel>
                    </TabItem.Header>
                    <TabItem.Content>
                        <Grid>
                            <DataGrid Name="_ctlGridPrimary" AutoGenerateColumns="False" IsReadOnly="True">
                                <DataGrid.Columns>
                                    <DataGridTextColumn Header="名称" Width="*" Binding="{Binding Path=Name}"/>
                                    <DataGridTextColumn Header="描述" Width="*" Binding="{Binding Path=Caption}"/>
                                </DataGrid.Columns>
                            </DataGrid>
                        </Grid>
                    </TabItem.Content>
                </TabItem>
            </TabControl>
        </Grid>
    </Grid>
</Page>
